import Facade from "./Facade";
import Notification from "./Notification";
import ObserverMap from "./ObserverMap";

export default abstract class Notifier {
    //key,是存储到队列里的唯一关键字
    //格式：视图名字：“模块名.view+名字”，如“login.LoginView”;
    //控制器名字：“login.LoginPresenter”;
    //数据模型名字：“login.LoginProxy”。
    //这里是用路径名称，要注意大小写。
    private _name: string = "";

    public setName(name: string) {
        if (name == null || name == "") {
            console.error("name is empty");
        }
        this._name = name;
    }
    public getName(): string {
        return this._name;
    }

    constructor(name?: string) {
        if (name) {
            this.setName(name);
        }
    }

    //消息队列，注册时会自动绑定
    public listNotificationInterests() {
        let list: Array<string> = [];
        return list;
    }

    //发送消息
    public sendNotification(name: string, body?: any, type?: string) {
        Facade.getInstance().sendNotification(name, body, type);
    }


    //消息响应
    public handleNotification(noti: Notification) { }

    //注册事件
    public onRegister() { }

    //移除事件
    public onRemove() { }
};